@inherits LayoutComponentBase
@using Application.Service.Auth
@using Application.Web.Core.Services
@inject AuthService AuthService
@inject NavigationManager Navigation

<Layout ShowGotoTop="false" ShowCollapseBar="true" ShowFooter="@ShowFooter" SideWidth="0"
        IsPage="true" IsFullSide="@IsFullSide" IsFixedHeader="@IsFixedHeader" IsFixedFooter="@IsFixedFooter"
        ShowSplitBar="false" SidebarMinWidth="200" SidebarMaxWidth="350"
        TabStyle="TabStyle.Chrome" ShowToolbar="true" ShowTabContextMenu="true"
        ShowTabInHeader="@ShowTabInHeader" ShowTabExtendButtons="false"
        TabDefaultUrl="/" UseTabSet="@UseTabSet" IsFixedTabHeader="@IsFixedTabHeader"
        AdditionalAssemblies="new[] { GetType().Assembly }"
        Menus="@_menus" class="@Theme">
    <Header>
        @if (ShowTabInHeader == false)
        {
            <span class="ms-3 flex-sm-fill d-none d-sm-block">Bootstrap of Blazor</span>
            <div class="flex-fill d-sm-none"></div>
            @* <Widget></Widget> *@
        }
        <div class="layout-drawer" style="margin-right: 20px;" @onclick="@(async e => { OpenMessages = !OpenMessages; await Task.CompletedTask; })"><i class="fa-solid fa-bell"></i></div>
        <Logout ImageUrl="images/Argo-C.png" DisplayName="@CurrentUserDisplayName" UserName="@CurrentUserName">
                <LinkTemplate>
                    <a href="javascript:void(0)" @onclick="@(async () => await ShowPersonalCenter())"><i class="fa-solid fa-suitcase"></i>个人中心</a>
                    <a href="javascript:void(0)"><i class="fa-solid fa-cog"></i>设置</a>
                    <a href="javascript:void(0)"><i class="fa-solid fa-bell"></i>通知<span class="badge badge-pill badge-success"></span></a>
                    <Application.Web.Entry.Shared.LogoutLink></Application.Web.Entry.Shared.LogoutLink>
                </LinkTemplate>
            </Logout>
        <div class="layout-drawer" style="display:none" @onclick="@(async e => { IsOpen = !IsOpen; await Task.CompletedTask; })"><i class="fa fa-gears"></i></div>
    </Header>
        <Side>
            <div class="layout-banner">
                <img class="layout-logo" src="../images/logo.png" />
                <div class="layout-title">
                    <span>信站管理</span>
                </div>
            </div>
            @* <div class="sidebar-content">
                @if (_menus != null)
                {
                    <Menu Items="_menus" IsVertical="true" />
                }
                else
                {
                    <div class="text-center p-3">
                        <div class="spinner-border" role="status">
                            <span class="visually-hidden">Loading...</span>
                        </div>
                    </div>
                }
            </div> *@
        </Side>
    <Footer>
        <div class="text-center flex-fill">
            <a class="page-layout-demo-footer-link" href="https://www.hthykj.com/" target="_blank">湖南航天环宇通信科技股份有限公司</a>
        </div>
    </Footer>
</Layout>

<Drawer Placement="Placement.Right" @bind-IsOpen="@IsOpen" IsBackdrop="true" OnClickBackdrop="@(async () => { IsOpen = false; await Task.CompletedTask; })">
    <div class="layout-drawer-body">
        <div class="btn btn-info w-100" @onclick="@(() => IsOpen = false)">点击关闭</div>
        <GroupBox Title="布局调整" >
            <div class="row">
                <div class="col-6">
                    <LayoutPreview IsFullSide="true" IsActive="IsFullSide" OnClick="OnSideChanged"></LayoutPreview>
                </div>
                <div class="col-6">
                    <LayoutPreview IsFullSide="false" IsActive="!IsFullSide" OnClick="OnSideChanged"></LayoutPreview>
                </div>
            </div>
        </GroupBox>

        <GroupBox Title="固定调整">
            <div class="row">
                <div class="col-6">
                    <Switch @bind-Value="@IsFixedHeader" OnColor="@Color.Success"></Switch>
                </div>
                <div class="col-6">
                    <span class="cell-label">固定页头</span>
                </div>
                <div class="col-6">
                    <Switch @bind-Value="@IsFixedFooter" OnColor="@Color.Success"></Switch>
                </div>
                <div class="col-6">
                    <span class="cell-label">固定页脚</span>
                </div>
                <div class="col-6">
                    <Switch @bind-Value="@ShowFooter" OnColor="@Color.Success"></Switch>
                </div>
                <div class="col-6">
                    <span class="cell-label">显示页脚</span>
                </div>
            </div>
        </GroupBox>

        <GroupBox Title="更多设置">
            <div class="row">
                <div class="col-6">
                    <Switch @bind-Value="@UseTabSet" OnColor="@Color.Success"></Switch>
                </div>
                <div class="col-6">
                    <span class="cell-label">@(UseTabSet ? "多标签" : "单页")</span>
                </div>
                <div class="col-6">
                    <Switch @bind-Value="@IsFixedTabHeader" OnColor="@Color.Success"></Switch>
                </div>
                <div class="col-6">
                    <span class="cell-label">固定标签页</span>
                </div>
                <div class="col-6">
                    <Switch @bind-Value="@ShowTabInHeader" OnColor="@Color.Success"></Switch>
                </div>
                <div class="col-6">
                    <span class="cell-label">@(ShowTabInHeader ? "顶栏标签" : "正常标签")</span>
                </div>
            </div>
        </GroupBox>
    </div>
</Drawer>

<Drawer Placement="Placement.Right" @bind-IsOpen="@OpenMessages" IsBackdrop="true" OnClickBackdrop="@(async () => { OpenMessages = false; await Task.CompletedTask; })">
    <div class="layout-drawer-body">
         <LogDrawer></LogDrawer>
    </div>
    <div class="btn btn-info w-100" style="margin-top: 10px;" @onclick="@(() => OpenMessages = false)">点击关闭</div>
</Drawer>

<!-- 修改密码模态框组件 -->
<PasswordChangeModal @ref="PasswordChangeModalRef" 
                     CurrentUserDisplayName="@CurrentUserDisplayName" 
                     CurrentUserName="@CurrentUserName" 
                     CurrentUserId="@CurrentUserId"
                     OnPasswordChanged="HandlePasswordChanged" />


@* <!-- 锁屏JavaScript -->
<script src="js/lockScreenInterop.js"></script> *@

@code {
    private void Logout()
    {
        AuthService.Logout();
        Navigation.NavigateTo("/", true);
    }
}
